package app_log

import (
	"fmt"
)

//  Print log message to system console
type ConsoleLogger struct {
	level LogLevel
}

var levelIconMap = map[LogLevel]string{
	LogLevelDebug:   "🐞",
	LogLevelLog:     "🗒",
	LogLevelWarning: "⚠️",
	LogLevelError:   "❌",
	LogLevelFatal:   "❌",
}

func (logger *ConsoleLogger) Log(message LogMessage) {
	dateStr := message.Date.Format("2006-01-02 15:04:05.000000 -07")
	var str = fmt.Sprintf("%s %s⎜ %s", levelIconMap[message.Level], dateStr, message.Message)
	var colorStr = NewColorString(str)

	switch message.Level {
	case LogLevelDebug:
		colorStr = colorStr.Cyan()
	case LogLevelLog:
	case LogLevelWarning:
		colorStr = colorStr.Yellow()
	case LogLevelError:
		colorStr = colorStr.Red()
	case LogLevelFatal:
		colorStr = colorStr.Red().Highlight()
	}
	fmt.Println(colorStr.Str())
}

func (logger *ConsoleLogger) LoggerDidRegistered() {

}

func (logger *ConsoleLogger) LoggerDidUnRegistered() {

}
